import 'package:flutter/material.dart';

///
///2行的菜单，可用于地址
///
class ItemMenu2 extends StatelessWidget {
  final String title, subtitle, leftIcon, rightIcon;
  final double textSize, subTextSize, leftIconEdge, rightIconEdge;
  final Color textColor, subTextColor;
  ItemMenu2(
      {this.title,
      this.subtitle,
      this.leftIcon,
      this.textSize: 18.0,
      this.subTextSize: 15.0,
      this.leftIconEdge = 20.0,
      this.rightIconEdge = 18.0,
      this.textColor: Colors.black,
      this.subTextColor: Colors.grey,
      this.rightIcon})
      : super();

  @override
  Widget build(BuildContext context) {
    Widget widget = Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text(
          '$title',
          style: TextStyle(
            fontSize: textSize,
            color: textColor,
          ),
        ),
        Text(
          '$subtitle',
          style: TextStyle(fontSize: subTextSize, color: subTextColor),
        ),
      ],
    );
    if (leftIcon != null || rightIcon != null) {
      final widgets = List<Widget>();
      if (leftIcon != null) {
        widgets.add(Container(
          child: Image.asset(
            '$leftIcon',
            width: leftIconEdge,
            height: leftIconEdge,
          ),
          margin: EdgeInsets.only(right: 10.0),
        ));
      }
      widgets.add(Expanded(
        child: widget,
      ));
      if (rightIcon != null) {
        widgets.add(Container(
          child: Image.asset(
            '$rightIcon',
            width: rightIconEdge,
            height: rightIconEdge,
          ),
          margin: EdgeInsets.only(left: 10.0),
        ));
      }
      widget = Row(
        children: widgets,
      );
    }
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 10.0),
      child: widget,
      color: Colors.white,
    );
  }
}
